<template>
	<view class="vote">
		<text class="vote-desc">{{voteVo.question}}</text>
		<view  v-for="item in voteVo.voteAnswer" v-bind:key="item.pkId" class="vote-bar" @click="testReq">
			<view class="bar-bg">
			<!-- 	"width:calc(1/{{bigTotal}}*100%);" -->
				<view :style="{width:getWidth(item,bigTotal) + '%'}" class="bar"></view>				
				<!-- <view :style="{width:'calc(1/2*100%)'}" class="bar"></view>	 -->
				<view class="bar-info">
					<text class="vote-item-info">{{item.answer}}</text>
					<!-- <text>{{bigTotal}}</text> -->
					<!-- <text>{{item.falseVoterNum+item.trueVoterNum}}/{{voteVo.falseJoinNum+voteVo.trueJoinNum}}</text> -->
					<text class="vote-item-number">{{item.falseVoterNum+item.trueVoterNum}}</text>
				</view>
			</view>
			<icon type="" :class="item.join?'fontIcon icon-select icon-select-selected':'fontIcon icon-unselect'"></icon>
			<!-- 	<icon type="" v-if="item.join" class="fontIcon icon-unselect"></icon>
				<icon type="" v-if="item.join" class="fontIcon icon-select"></icon> -->
		</view>
	<!-- 	<view class="vote-bar" @click="testReq">
			<view class="bar-bg">
				<view class="bar" style="width:calc( 17/300 * 100% );"></view>
				<view class="bar-info">
					<text class="vote-item-info">第二个版本</text>
					<text class="vote-item-number">17</text>
				</view>
			</view>
			<icon type="" class="fontIcon icon-unselect"></icon>
		</view> -->
		<view class="vote-info">
			<text class="people-number">参加人数:{{voteVo.falseJoinNum+voteVo.trueJoinNum}}</text>
			<text class="state">已结束</text>
			<text class="creater" @click="testReq"><span class=" quote-text">@{{userVo.nickName}}</span>创建</text>
		</view>
	</view>
</template>

<script setup lang="ts">
import type { IUserVo } from '@/logic/globInterface/dataInterface';
import { reactive,ref,watch} from 'vue';
		const getWidth = (item:any,bigTotal:any) =>{
			return (item.falseVoterNum+item.trueVoterNum)/bigTotal *100
			
		}
	interface aaa {
			answer:string,
			falseVoterNum:number,
			pkId:string,
			trueVoterNum:number,
			join:boolean

	}
	// type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes];
	interface Props {
		userVo:IUserVo
		voteVo:{
			createDate:number,
			voteAnswer:Array<aaa>,
			pkId:string,
			falseJoinNum:number,
			trueJoinNum:number,
			question:string,
			cigarUser:{}
		}
	}
	const props=defineProps<Props>()
	const userVo=reactive((props.userVo))
	const voteVo=reactive(props.voteVo)
	const bigTotal=ref(0)
	watch( voteVo,(oldVaule,changeValue)=>{
		bigTotal.value=voteVo.falseJoinNum+voteVo.trueJoinNum
	// console.log('6767',voteVo.voteAnswer[0].falseVoterNum)
		// if(bigTotal?0:'')
		// console.log(bigTotal,'9090')
	})
	console.log('555',voteVo.cigarUser)
	console.log(voteVo.voteAnswer)
</script>

<style>
</style>